package com.zhanghuan.scheduler.exceptionHandler;

import com.zhanghuan.scheduler.job.entity.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ValicadeHandler {
    @ExceptionHandler(Throwable.class)
    @ResponseBody
    public R exceptionHandler(Throwable e){
        Logger logger = LoggerFactory.getLogger(getClass());
        logger.error(e.toString());
        return R.error(e.toString());
    }

}
